home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000091_icon-group-sender _Sat Mar 22 16:50:45 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Sat, 22 Mar 1997 16:12:10 MST
  2. To: icon-group@cs.arizona.edu
  3. Date: 22 Mar 1997 16:50:45 GMT
  4. From: espie@drakkar.ens.fr (Marc Espie)
  5. Message-Id: <5h12l5$6m3$1@nef.ens.fr>
  6. Organization: Ecole Normale Superieure, Paris
  7. Sender: icon-group-request@cs.arizona.edu
  8. References: <33338AEF.420@anu.edu.au>
  9. Subject: Re: Problem with Program
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11. Status: RO
  12. Content-Length: 1123
  13.  
  14. In article <33338AEF.420@anu.edu.au>,
  15. Stuart Robinson  <Stuart.Robinson@anu.edu.au> wrote:
  16. >Hello.
  17. >
  18. >I've run into a problem with a program that I've written and I was 
  19. >hoping that someone would tell what is wrong.  I'm sure it's silly and 
  20. >stupid but I am a newcomer to programming in general and Icon in 
  21. >particular.
  22. >
  23. >This short little program is meant to read a line and write either (1) 
  24. >a tab followed by the line or (2) simply the line.  It should do (1) 
  25. >if the line either contains "{Q" or follows a line with "{Q"; 
  26. >otherwise, it should do (2).
  27.  
  28. Relax your strategy, it will work better:
  29.  
  30. procedure main()
  31.     while line := read() do
  32.         if find("{Q", line) then
  33.             {
  34.             write("\t"||line)
  35.             write("\t"||read())
  36.             }
  37.         else
  38.             write(line)
  39. end
  40.  
  41. - using string scanning is more confusing than anything in that context.
  42. - you have to use two write() for the comments case, as read() can fail.
  43. -- 
  44. [nosave]<http://www.eleves.ens.fr:8080/home/espie/index.html>
  45. microsoft network is EXPLICITLY forbidden to redistribute this message.
  46. `Seiza no matataki kazoe, uranau koi no yuku e.'
  47.     Marc Espie (Marc.Espie@ens.fr)
  48.